//number,rpx,upx,px,% --> px的数值
export const toPx = num => {
	if (typeof num === 'string') {
		if (num.indexOf('px') !== -1) {
			if (num.indexOf('rpx') !== -1) {
				// "10rpx"
				num = num.replace('rpx', '');
			} else if (num.indexOf('upx') !== -1) {
				// "10upx"
				num = num.replace('upx', '');
			} else {
				// "10px"
				return Number(num.replace('px', ''));
			}
		} else if (num.indexOf('%') !== -1) {
			// 传百分比,则相对于windowHeight,传"10%"则等于windowHeight的10%
			let rate = Number(num.replace('%', '')) / 100;
			return this.windowHeight * rate;
		}
	}
	return num ? uni.upx2px(Number(num)) : 0;
};
